//---------------------------------------------------------------------------
//
// Name:        RSSFilterFrame.h
// Author:      gurkesaft
// Created:     7/29/2007 10:33:08 PM
// Description: RSSFilterFrame class declaration
//
//---------------------------------------------------------------------------

#ifndef __RSSFILTERFRAME_h__
#define __RSSFILTERFRAME_h__

#ifdef __BORLANDC__
	#pragma hdrstop
#endif

#ifndef WX_PRECOMP
	#include <wx/wx.h>
	#include <wx/frame.h>
#else
	#include <wx/wxprec.h>
#endif

//Do not add custom headers between 
//Header Include Start and Header Include End.
//wxDev-C++ designer will remove them. Add custom headers after the block.
////Header Include Start
#include <wx/timer.h>
#include <wx/spinctrl.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <wx/textctrl.h>
#include <wx/listbox.h>
#include <wx/panel.h>
////Header Include End

////Dialog Style Start
#undef RSSFilterFrame_STYLE
#define RSSFilterFrame_STYLE wxCAPTION | wxSYSTEM_MENU | wxMINIMIZE_BOX | wxCLOSE_BOX
////Dialog Style End

#include <wx/textfile.h>
#include <wx/uri.h>
#include <wx/url.h>
#include <wx/html/htmlcell.h>
#include <wx/utils.h>
#include <wx/thread.h>
#include <wx/textdlg.h>
#include <wx/datetime.h>
#include <wx/xml/xml.h>
#include "standalones.h"
#include "htmlFrame.h"
#include "JaxTaskbarIcon.h"
#include "Article.h"


class htmlFrame;
class JaxTaskBarIcon;
class Article;
class ArticleList;

class JaxInputStream : wxInputStream
{
    public:
        wxString GetEverything();
};



class RSSFilterFrame : public wxFrame
{
	private:
		DECLARE_EVENT_TABLE();
		
	public:
		RSSFilterFrame(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("RSSFilter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = RSSFilterFrame_STYLE);
		virtual ~RSSFilterFrame();
		void buttonFetchClick(wxCommandEvent& event);
		int  FilterString(wxString s, wxString filter_string);
		void LinkClicked(wxHtmlLinkEvent &link_event);
		void buttonShowClick(wxCommandEvent& event);
        void FilterAndShow();
        void ShowFiltered();
        void Fetch();
        void Log(wxString s);
        void Debug(wxString s, int level=0);
        void AddToPuked(Article feed);
        wxString GetNodeContent(wxXmlNode *node, wxString name);
        void FetchSingleFeed(Article feed);
        void RecursivelyLoopOverNodes(wxXmlNode *start, wxString &feed_title);
        
		wxString s;      // all-purpose
        htmlFrame *html; // this is where the html goes
        
        ArticleList master;
        ArticleList filtered;
		ArticleList feeds;
		ArticleList puked;
		wxArrayString undo;
		
		wxIcon some, none, updating, shit;
        JaxTaskBarIcon *tray;
        
		//Do not add custom control declarations between
		//GUI Control Declaration Start and GUI Control Declaration End.
		//wxDev-C++ will remove them. Add custom code after the block.
		////GUI Control Declaration Start
		wxTimer *timerFetchSingle;
		wxTimer *timerFetch;
		wxButton *buttonFetch;
		wxButton *buttonShow;
		wxButton *buttonRecall;
		wxButton *buttonNewFeed;
		wxButton *buttonRemoveFeed;
		wxCheckBox *checkBoxUberdebug;
		wxTextCtrl *editEmail;
		wxStaticText *WxStaticText8;
		wxSpinCtrl *spinLimit;
		wxCheckBox *checkBoxLimit;
		wxStaticText *WxStaticText7;
		wxStaticText *WxStaticText6;
		wxStaticText *WxStaticText5;
		wxCheckBox *checkBoxDebug;
		wxButton *buttonQuit;
		wxTextCtrl *memoLog;
		wxButton *buttonUberFetch;
		wxStaticText *WxStaticText4;
		wxStaticText *WxStaticText3;
		wxStaticText *WxStaticText2;
		wxStaticText *WxStaticText1;
		wxTextCtrl *editReject;
		wxCheckBox *checkBoxCreator;
		wxCheckBox *checkBoxDescription;
		wxCheckBox *checkBoxTitle;
		wxTextCtrl *editFilter;
		wxListBox *listURLs;
		wxPanel *panelMain;
		////GUI Control Declaration End
		
		void buttonQuitClick(wxCommandEvent& event);
		void buttonRecallClick(wxCommandEvent& event);
		void timerFetchTimer(wxTimerEvent& event);
		bool Status();
		
		int fetching;
		
        void buttonRemoveFeedClick(wxCommandEvent& event);
		void buttonNewFeedClick(wxCommandEvent& event);
		void editFilterEnter(wxCommandEvent& event);
		void editRejectEnter(wxCommandEvent& event);
		
		void LoadConfiguration();
		void SaveConfiguration();
		void Quit();
		void buttonUberFetchClick(wxCommandEvent& event);
		void timerFetchSingleTimer(wxTimerEvent& event);
		void checkBoxLimitClick(wxCommandEvent& event);
		void checkBoxTitleClick(wxCommandEvent& event);
		void panelMainUpdateUI(wxUpdateUIEvent& event);
		void listURLsDoubleClicked(wxCommandEvent& event);
		
	private:
		//Note: if you receive any error with these enum IDs, then you need to
		//change your old form code that are based on the #define control IDs.
		//#defines may replace a numeric value for the enum names.
		//Try copy and pasting the below block in your old form header files.
		enum
		{
			////GUI Enum Control ID Start
			ID_TIMERFETCHSINGLE = 1044,
			ID_TIMERFETCH = 1022,
			ID_BUTTONFETCH = 1043,
			ID_BUTTONSHOW = 1041,
			ID_BUTTONRECALL = 1039,
			ID_BUTTONNEWFEED = 1061,
			ID_BUTTONREMOVEFEED = 1060,
			ID_CHECKBOXUBERDEBUG = 1058,
			ID_EDITEMAIL = 1057,
			ID_WXSTATICTEXT8 = 1056,
			ID_SPINLIMIT = 1055,
			ID_CHECKBOXLIMIT = 1051,
			ID_WXSTATICTEXT7 = 1050,
			ID_WXSTATICTEXT6 = 1049,
			ID_WXSTATICTEXT5 = 1047,
			ID_CHECKBOXDEBUG = 1046,
			ID_BUTTONQUIT = 1045,
			ID_MEMOLOG = 1027,
			ID_BUTTONUBERFETCH = 1026,
			ID_WXSTATICTEXT4 = 1015,
			ID_WXSTATICTEXT3 = 1013,
			ID_WXSTATICTEXT2 = 1012,
			ID_WXSTATICTEXT1 = 1011,
			ID_EDITREJECT = 1010,
			ID_CHECKBOXCREATOR = 1009,
			ID_CHECKBOXDESCRIPTION = 1008,
			ID_CHECKBOXTITLE = 1007,
			ID_EDITFILTER = 1006,
			ID_LISTURLS = 1003,
			ID_PANELMAIN = 1001,
			////GUI Enum Control ID End
			ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
		};
		
	private:
		void OnClose(wxCloseEvent& event);
		void CreateGUIControls();
};

#endif
